package com.snnsh.kjb.lottery.util;

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.Calendar;
import java.util.Date;

/**
 * packageName com.snnsh.kjb.lottery.util
 *
 * @author wick
 * @version V1.0.0
 * @date 2025/5/27
 */
public class Tools {
    /**
     * 获取当前应用程序类路径的通用方法
     * @return 类路径
     */
    public static String getClassPath(){
        String path = Tools.class.getClassLoader().getResource("").getPath().toString();
        try {
            path =  URLDecoder.decode(path,"utf-8");
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        return path;
    }

    /**
     * 构建Date对象的通用方法
     * @param year  年
     * @param month 月
     * @param date  日
     * @return
     */
    public static Date toDate(int year, int month, int date){
        Date dates  = null;
        java.util.Calendar cal = Calendar.getInstance();
        cal.set(Calendar.YEAR,year);
        cal.set(Calendar.MONTH,month-1);
        cal.set(Calendar.DATE,date);
        dates = cal.getTime();
        return dates;
    }
}
